package per.poker;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;

@SpringBootApplication
public class PokerApplication extends Application {

    private static String[] args;

    public static void main(String[] args) {
        PokerApplication.args = args;
        launch(args);
    }

    @Override
    public void init() {
        SpringApplicationBuilder builder = new SpringApplicationBuilder(PokerApplication.class);
        builder.headless(false).run(args);
    }

    @Override
    public void start(Stage stage) throws Exception {
        FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/scene/main.fxml"));
        Scene scene = new Scene(fxmlLoader.load());
        stage.setY(10);
        stage.setY(10);
        stage.setTitle("扑克牌");
        stage.setScene(scene);
        stage.setResizable(false);
        stage.setOnCloseRequest(event -> System.exit(0));
        stage.show();
    }

    @Override
    public void stop() throws Exception {
        super.stop();
        Platform.exit();
        Runtime.getRuntime().exit(0);
    }

}
